using I2.Loc;
using UnityEngine;

public class ButAwardMarathon : MonoBehaviour
{
	public UILabel lbDay;

	public UILabel lbNameCount;

	public UITexture txAward;

	public Color superDayTextColor;

	public Color dayTextColor;

	public Color curentDayTextColor;

	public GameObject prevDay;

	public GameObject prevSuperDay;

	public GameObject curDay;

	public GameObject nextDay;

	public GameObject nextSuperDay;

	private bool typeSDay;

	private DayMarathon curDayMarathon;

	public string locDay
	{
		get
		{
			return ScriptLocalization.Get("Lobby_X3/day");
		}
	}

	public void SetInfo(DayMarathon val, bool typeSuperDay)
	{
		if ((bool)prevSuperDay)
		{
			prevSuperDay.SetActive(false);
		}
		if ((bool)prevDay)
		{
			prevDay.SetActive(false);
		}
		if ((bool)curDay)
		{
			curDay.SetActive(false);
		}
		if ((bool)nextDay)
		{
			nextDay.SetActive(false);
		}
		if ((bool)nextSuperDay)
		{
			nextSuperDay.SetActive(false);
		}
		typeSDay = typeSuperDay;
		curDayMarathon = val;
		int num = -1;
		bool flag = val.curNumDayAward < MarathonController.instance.CountDayReceiveAward;
		bool flag2 = val.curNumDayAward == MarathonController.instance.CountDayReceiveAward;
		if (flag)
		{
			if (typeSuperDay || val.superDay)
			{
				if ((bool)prevSuperDay)
				{
					prevSuperDay.SetActive(true);
				}
			}
			else if ((bool)prevDay)
			{
				prevDay.SetActive(true);
			}
		}
		else if (flag2)
		{
			if ((bool)curDay)
			{
				curDay.SetActive(true);
			}
		}
		else if (val.superDay || typeSuperDay)
		{
			if ((bool)nextSuperDay)
			{
				nextSuperDay.SetActive(true);
			}
		}
		else if ((bool)nextDay)
		{
			nextDay.SetActive(true);
		}
		if (val.superDay && !flag2)
		{
			if ((bool)lbDay)
			{
				lbDay.color = superDayTextColor;
				lbNameCount.color = superDayTextColor;
			}
		}
		else if (flag2)
		{
			if ((bool)lbDay)
			{
				lbDay.color = curentDayTextColor;
				lbNameCount.color = curentDayTextColor;
			}
		}
		else if ((bool)lbDay)
		{
			lbDay.color = dayTextColor;
			lbNameCount.color = dayTextColor;
		}
		if ((bool)lbDay)
		{
			lbDay.text = locDay + " " + val.curNumDayAward;
		}
		string nameFor = MarathonWindow.instance.GetNameFor(val.idProduct);
		if ((bool)lbNameCount)
		{
			if (val.count > 1)
			{
				lbNameCount.text = val.count + " " + nameFor;
			}
			else
			{
				lbNameCount.text = nameFor;
			}
		}
		txAward.mainTexture = MarathonWindow.instance.GetTextureFor(val.idProduct);
	}

	private void OnClick()
	{
		if (typeSDay && curDayMarathon != null)
		{
			MarathonWindow.instance.ShowInfoAward(curDayMarathon);
		}
	}
}
